FROM rust:1.70 as builder

WORKDIR /app

COPY Cargo.toml Cargo.lock ./

RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
RUN cargo build --release

COPY . .

RUN cargo build --release


FROM debian:buster-slim

WORKDIR /app

COPY --from=builder /app/target/release/main .

RUN useradd -m appuser && \
    chown -R appuser:appuser /app

USER appuser

EXPOSE 8084

CMD ["./main"]
